// 导出reducer
import { getToken } from "@/utils/auth"
import * as types from "../actionType"
const initialState = {
  token: getToken(), // 这里从本地存储中读取token
  userInfo: {}, // 初始值
}

export default function user(state = initialState, action) {
  switch (action.type) {
    case types.SET_TOKEN:
      return { ...state, token: action.payload }
    case types.UPDATE_USERINFO:
      return { ...state, userInfo: action.payload }
    default:
      return state
  }
}
